package com.bw.Threads.pattern_LinkedBlockingQueue.pattern;

import java.util.concurrent.LinkedBlockingDeque;

public class Consumer implements Runnable{
    private LinkedBlockingDeque<String> backet;

    public Consumer(LinkedBlockingDeque<String> backet) {
        this.backet = backet;
    }

    @Override
    public void run() {
        while (true){
            try {
                backet.take();//取出  从阻塞队列中取出队列
                System.out.println(Thread.currentThread().getName()+"获取一个，剩余" + backet.size());
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
